package com.virga.splashscreen;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;

public class VirgasplashscreenActivity extends Activity {
    
	private static final int SPLASH_DISPLAY = 5000; /* 2 seconds */
	
	MediaPlayer logoMusic;
	
	/**Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);
		
		
		/*Create a new handler which will start the main activity
		 * after the splash screen has shown on the screen for the
		 * SPLASH_DISPLAY time.
		 */
		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				
				/**Create intent that will start main activity. */
				Intent mainIntent = new Intent(VirgasplashscreenActivity.this, main.class);
				VirgasplashscreenActivity.this.startActivity(mainIntent);
				
				/**Finish splash screen activity so the user cannot go back to it. */
				VirgasplashscreenActivity.this.finish();
				
				/**Apply our entry into splash screen. */
				overridePendingTransition(R.anim.splashfadein, R.anim.splashfadeout);
				
			}
			
		}, SPLASH_DISPLAY );
		
		/**Plays music for the user to hear during the splash screen. */
		logoMusic = MediaPlayer.create(VirgasplashscreenActivity.this, R.raw.virgasplashmusic);
		logoMusic.start();
	}
	
	
}